From 1bd54c9db6b0207c27142bb513495508a60ed803 Mon Sep 17 00:00:00 2001 From: "jrb44@plym.cl.cam.ac.uk" Date: Fri, 21 Oct 2005 18:51:42 +0100 Subject: [PATCH] Temporary workaround to xend start problem. Signed-off-by: James Bulpin --- tools/python/xen/util/process.py | 39 ++++++++++++++++++++++++++++++++ tools/python/xen/xend/Vifctl.py | 6 +++-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tools/python/xen/util/process.py diff --git a/tools/python/xen/util/process.py b/tools/python/xen/util/process.py new file mode 100644 index 0000000000..9117ef4ded --- /dev/null +++ b/tools/python/xen/util/process.py @@ -0,0 +1,39 @@ +# Copyright (C) 2005 Christian Limpach + +# os.system() replacement which outputs through the logger + +import popen2 +import select +import string + +from xen.xend.XendLogging import log + +def runscript(cmd): + # split after first space, then grab last component of path + cmdname = "[%s] " % cmd.split()[0].split('/')[-1] + # run command and grab stdin, stdout and stderr + cout, cin, cerr = popen2.popen3(cmd) + # close stdin to get command to terminate if it waits for input + cin.close() + # wait for output and process + p = select.poll() + p.register(cout) + p.register(cerr) + stdout = "" + while True: + r = p.poll() + for (fd, event) in r: + if event == select.POLLHUP: + cout.close() + cerr.close() + return stdout + if fd == cout.fileno(): + stdout = stdout + cout.readline() + if fd == cerr.fileno(): + l = cerr.readline() + if l[0] == '-': + log.debug(cmdname + l[1:].rstrip()) + elif l[0] == '*': + log.info(cmdname + l[1:].rstrip()) + else: + log.error(cmdname + l.rstrip()) diff --git a/tools/python/xen/xend/Vifctl.py b/tools/python/xen/xend/Vifctl.py index 382cba5c04..fe37dfc506 100644 --- a/tools/python/xen/xend/Vifctl.py +++ b/tools/python/xen/xend/Vifctl.py @@ -20,9 +20,9 @@ """ import os +import xen.util.process import XendRoot - def network(op): """Call a network control script. @@ -32,4 +32,6 @@ def network(op): raise ValueError('Invalid operation: ' + op) script = XendRoot.instance().get_network_script() if script: - os.spawnl(os.P_WAIT, script, script, op) + xen.util.process.runscript(script + " " + op) + #os.spawnl(os.P_WAIT, script, script, op) + -- 2.30.2